import java.util.Stack;

class Solution {
    public int evalRPN(String[] tokens) {
        Stack<Integer>  stack = new Stack<>();
        for (String X : tokens){
            if (!(X.equals("+")||X.equals("-")||X.equals("*")||X.equals("/"))){
                stack.push(Integer.parseInt(X) );//类型转换
            } else {
                int a=stack.pop();
                int b=stack.pop();
                switch (X){
                    case "+":
                        stack.push(b+a);
                        break;
                    case "-":
                        stack.push(b-a);
                        break;
                    case "*":
                        stack.push(b*a);
                        break;
                    case "/":
                        stack.push(b/a);
                        break;

                }
            }
        }
        return stack.pop();
    }
}

public class Text2 {
}
